﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;

namespace BaoVeBienCuong
{
    class Diem
    {
        Vector2 position;
        Vector2 curposition;
        private Texture2D images;
        private float scale;
        private long diem;
        private int i;
        private bool isAdd;
        public Diem()
        {
            position = new Vector2(0, 0);
            curposition = new Vector2(0, 0);
            scale = 0.5f;
            i = 0;
            isAdd = true;
        }
        public void Load(ContentManager content)
        {
            images = content.Load<Texture2D>("so");
        }
        public void setDiemBay(Vector2 position, long diem, bool a)
        {
            i = 0;
            isAdd = a;
            this.position = position;
            curposition = position;
            this.diem = diem;
        }
        public void Draw(SpriteBatch sprite)
        {
            string temp = diem.ToString();
            curposition = position - new Vector2(0, 4) * i;
            if (i != -1)
            {
                for (int j = 0; j < temp.Length; j++)
                {
                    sprite.Draw(images, curposition + new Vector2(j * 60 * scale, 0),
                        new Rectangle(Int16.Parse(temp.Substring(j, 1)) * 96, 0, 96, 85)
                        , (isAdd ? Color.White : Color.Red), 0, Vector2.Zero, scale, SpriteEffects.None, 0);
                }
                i++;
            }
            if (i == 30)
            {
                i = -1;
            }
        }
    }
}
